<?php

class Db_OrderAddress extends Common {
    protected static $tableName = TAB_ORDER_ADDRESS;
    protected static $dbFields = array(
        'id',
        'ad_orders_id',
        'ad_title',
        'ad_company_name',
        'ad_name',
        'ad_first_name',
        'ad_post_box',
        'ad_street',
        'ad_number',
        'ad_post_code',
        'ad_pack_station',
        'ad_city',
        'ad_country_id',
        'ad_telephone',
        'ad_email',
        'ad_solution_id',
        'ad_type',
        'deleted'
    );

    public $objectArray;

    public $id;
    public $ad_orders_id;
    public $ad_title;
    public $ad_company_name;
    public $ad_name;
    public $ad_number;
    public $ad_street;
    public $ad_first_name;
    public $ad_post_box;
    public $ad_post_code;
    public $ad_pack_station;
    public $ad_city;
    public $ad_country_id;
    public $ad_telephone;
    public $ad_email;
    public $ad_solution_id;
    public $ad_type;
    public $deleted;

    function __construct($value=NULL, $fieldName=NULL) {
        parent::__construct($value, $fieldName);
    }

	public static function getUserFormDataByOrderId($orderId) {
		$orderAddresses = self::findAllByField('ad_orders_id', $orderId);
		if(!empty($orderAddresses)) {
			foreach($orderAddresses as $orderAddress) {
				$orderAddresses['result'][$orderAddress->ad_type] = $orderAddress;
			}
			return $orderAddresses['result'];
		}
		return false;
	}


}